package TaskStructure
{
	import flash.events.Event;
	import flash.utils.getTimer;
	
	/** This Event class is used to declare events that should be logged.  Events should bubble up so that one main class
	 * can actually log everything.
	 */ 
	public class LogEvent extends Event
	{
		// list of type of log events - specific to project - can change by project
		public static const ANY:String = "any"; // generic
		public static const OBJECT_ADDED:String = "object_added"; // direct_name = "subject1" where1 = "" x1 = 200 y1 = 200, indirect_name="" etc
		public static const OBJECT_REMOVED:String = "object_removed";
		public static const OBJECT_MOVED:String = "object_moved";
		public static const OBJECTS_MATCHED:String = "objects_matched"; // direct_name="unit" where1 = "left" x1=100 y1 = 100 indirect_name = "variable" etc
		public static const OBJECTS_UNMATCHED:String = "objects_unmatched";
		public static const NUMBERS_SWITCHED:String = "numbers_switched";
		public static const OPERATION_SELECTED:String = "operation selected"; // direct_name="=" where = "left"
		public static const TRANSITION:String = "transition";
		
		private var _timestamp:uint;
		public function get timestamp():uint{return _timestamp;}
		
		private var _sub_type:String;
		override public function get type():String{return _sub_type;}
		
		private var _direct_name:String;
		/** Name of object being directly manipulated */
		public function get direct_name():String{return _direct_name;}
		
		private var _indirect_name:String;
		/** Name of object being indirectly manipulated (in action modeler) */
		public function get indirect_name():String{return _indirect_name;}
		
		private var _direct_where:String;
		/** Description of where direct object is initially located */
		public function get direct_where():String{return _direct_where;}
		
		private var _indirect_where:String;
		/** Description of where indirect object is initially located */
		public function get indirect_where():String{return _indirect_where;}
		
		private var _direct_x:Number, _direct_y:Number;
		/** Initial x location of direct object */
		public function get direct_x():Number{return _direct_x;}	
		/** Initial y location of direct object */
		public function get direct_y():Number{return _direct_y;}
		
		private var _indirect_x:Number, _indirect_y:Number;
		/** Initial x location of direct object */
		public function get indirect_x():Number{return _indirect_x;}	
		/** Initial y location of direct object */
		public function get indirect_y():Number{return _indirect_y;}
		
		public function LogEvent(type:String, _direct_name:String, _direct_where:String, _direct_x:Number, _direct_y:Number, _indirect_name:String="", _indirect_where:String="", _indirect_x:Number=Number.NaN, _indirect_y:Number=Number.NaN, bubbles:Boolean=true, cancelable:Boolean=false)
		{
			super(ANY, bubbles, cancelable);
			this._timestamp = flash.utils.getTimer();
			this._sub_type = type;
			this._direct_name = _direct_name;
			this._direct_where = _direct_where;
			this._direct_x = _direct_x;
			this._direct_y = _direct_y;
			this._indirect_name = _indirect_name;
			this._indirect_where = _indirect_where;
			this._indirect_x = _indirect_x;
			this._indirect_y = _indirect_y;
			
		}
		/** Writes all properties as comma separated string */
		override public function toString():String
		{
			return String(this.timestamp + "," +  this.type + "," + this.direct_name + "," + this.direct_where + "," + this.direct_x + "," + this.direct_y + "," + this.indirect_name + "," + this.indirect_where + "," + this.indirect_x + "," + this.indirect_y);  
		}
		/** Gives names of all constants */
		static public function TOSTRING():String
		{
			return String("PROBLEM_NUMBER" + "," + "TIMESTAMP" + "," +  "TYPE" + "," + "DIRECT_NAME" + "," + "DIRECT_WHERE" + "," + "DIRECT_X" + "," + "DIRECT_Y" + "," + "INDIRECT_NAME" + "," + "INDIRECT_WHERE" + "," + "INDIRECT_X" + "," + "INDIRECT_Y");  
		}
	}
}